package com.test.utils;

import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import net.masterthought.cucumber.Reportable;
import net.masterthought.cucumber.presentation.PresentationMode;
import net.masterthought.cucumber.sorting.SortingMethod;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class ReportUtils {
    public void generateCucumberReport(){
        String buildNumber = "Release 23.12";
        String projectName = "Test Demo";
        File reportOutputDirectory = new File("target");
        List<String> jsonFiles = new ArrayList<>();
        // 根据cucumber生成的原始json报告去生成测试报告
        jsonFiles.add("target/json-report/run.json");
        // 测试报告配置信息目录，项目名称
        Configuration configuration = new Configuration(reportOutputDirectory,projectName);
        // 测试报告版本
        configuration.setBuildNumber(buildNumber);
        // 测试报告展示模式
        configuration.addPresentationModes(PresentationMode.EXPAND_ALL_STEPS);
        configuration.addPresentationModes(PresentationMode.PARALLEL_TESTING);
        // 排序方式设置
        configuration.setSortingMethod(SortingMethod.ALPHABETICAL);

        configuration.addClassifications("Platform","Windows 11");
        configuration.addClassifications("Component","API Test");
        configuration.addClassifications("Version","23.12");
        configuration.addClassifications("User","Cacho");
        // json文件和配置一起去生成报告
        ReportBuilder reportBuilder = new ReportBuilder(jsonFiles,configuration);
        reportBuilder.generateReports();
    }
}
